package com.china08.yxyapi.repository.db;

import java.util.List;
import java.util.Set;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.china08.yxyapi.entity.db.res.YxyResVersion;

public interface YxyResVersionRepository extends JpaRepository<YxyResVersion, String> {

    /**
     * 根据ID修改
     * 
     * @param id
     */
    @Transactional
    void deleteById(String id);

    List<YxyResVersion> findByName(String name);

    /**
     * 
     * @param searchWords
     * @param searchWords2
     * @return
     */
    @Query(value = "SELECT version from YxyResVersion version where version.name Like %?1% OR version.descript  Like %?2%")
    Page<YxyResVersion> findByNameLikeOrDescriptLike(String searchWords, String searchWords2, Pageable pageable);

    YxyResVersion findTopByIdStartingWithOrderByIdDesc(String string);

    List<YxyResVersion> findByNameAndIdNot(String name, String id);

    List<YxyResVersion> findByIdInAndStatusOrderByOrderNum(List<String> versionIds, Integer status);

    YxyResVersion findById(String version);

    List<YxyResVersion> findByIdIn(Set<String> versionIds);
}
